<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

    <title> - 登录</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link href="${ctx!}/assets/css/bootstrap.min.css" rel="stylesheet">
    <link href="${ctx!}/assets/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="${ctx!}/assets/css/animate.css" rel="stylesheet">
    <link href="${ctx!}/assets/css/style.css" rel="stylesheet">
    <link href="${ctx!}/assets/css/login.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>

</head>

<body class="signin">
    <div class="signinpanel">
        <div style="margin-top: 300px" class="row">
            <div class="col-sm-12">
                <form method="post" action="${ctx!}/register" id="frm">
                    <h4 style="text-align: center" class="no-margins">· 注册 ·</h4>
                    <input type="text" class="form-control uname" name="userName" id="userName" placeholder="| 用户名" />
                    <input type="password" class="form-control pword m-b" name="plaintextPassword" id="plaintextPassword"  placeholder="| 密码" />
                    <button class="btn btn-block">注册</button>
                </form>
            </div>
        </div>
    </div>
    <div class="signup-footer">
        技术支持单位：南京达实能源技术有限公司
    </div>

     <!-- 全局js -->
    <script src="${ctx!}/assets/js/jquery.min.js?v=2.1.4"></script>
    <script src="${ctx!}/assets/js/bootstrap.min.js?v=3.3.6"></script>

    <!-- 自定义js -->
    <script src="${ctx!}/assets/js/content.js?v=1.0.0"></script>

    <!-- jQuery Validation plugin javascript-->
    <script src="${ctx!}/assets/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="${ctx!}/assets/js/plugins/validate/messages_zh.min.js"></script>
    <script src="${ctx!}/assets/js/plugins/layer/layer.min.js"></script>
	<script type="text/javascript">
    $(document).ready(function() {
    	// 在键盘按下并释放及提交后验证提交表单
    	  $("#frm").validate({
    	    rules: {
    	      userName: {
    	        required: true,
    	        minlength: 2
    	      },
                plaintextPassword: {
    	        required: true,
    	        minlength: 5
    	      }
    	    },
    	    messages: {
                userName: {
    	        required: "请输入用户名",
    	        minlength: "用户名必需由两个字母组成"
    	      },
                plaintextPassword: {
    	        required: "请输入密码",
    	        minlength: "密码长度不能小于 6 个字母"
    	      }
    	    },
              submitHandler:function(form){
                  $.ajax({
                      type: "POST",
                      dataType: "json",
                      // contentType:"application/json",
                      url: "${ctx!}/register",
                      data: $(form).serialize(),
                      success: function(msg){
                          console.log(msg);
                          layer.msg(msg.message, {time: 2000},function(){
                              if(msg.code===0)
                                  location.href="${ctx!}/login";
                          });
                      }
                  });
              }
    	});
    });
    
    </script>
</body>

</html>
